<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<!-- Angular Material style sheet -->
	<link rel="stylesheet" href="https://cdn.bootcss.com/angular-material/1.1.0/angular-material.min.css">
	<title>IntaLinx Mobile@beta</title>
</head>
<body ng-app="DownloadApp" ng-cloak>
  <!--
    Your HTML content here
  -->  
	<div ng-controller="DownloadCtrl" ng-cloak>
	  	<md-content class="md-padding" layout-xs="column" layout="row">
	  	
		<md-card>
			<div style="display:flex;justify-content:center;-webkit-justify-content:center;">
				<img src="icon.png">
			</div>
			<div style="display:flex;justify-content:center;-webkit-justify-content:center;">
				<qrcode size="100" data="https://intalinx.oschina.io/youbeile/" href="https://intalinx.oschina.io/youbeile/"></qrcode>
			</div>
		    <md-card-title>
		        <md-card-title-text>
		        	<span class="md-headline">IntaLinx Mobile@beta</span>
		        </md-card-title-text>
		    </md-card-title>
		    <md-card-content>
		        <p>
					请点击下面的链接下载安装IntaLinx Mobile最新版
		        </p>
		    </md-card-content>
		    <md-card-actions layout="row" layout-align="center center">
		    	<md-button id="downloadLink" style="display:none" md-no-ink class="md-primary" ng-show="!isWechat">
		    		<a ng-href="{{downloadURL}}" ng-click="download()">
		    		下载
		    		</a>
		    	</md-button>
		    	<a id="downloadLinkForWechat" style="display:none" href="#" ng-show="isWechat">
		    		请使用浏览器或者Safari打开网页。
	    		</a>
				<a id="downloadLinkForUnsupportBrowser" href="https://intalinx.oschina.io/youbeile/IntaLinxMobile.apk">
					下载
				</a>
		    </md-card-actions>
		</md-card>
		</md-content>
	</div>
  
  
  <!-- Angular Material requires Angular.js Libraries -->
	<script src="https://cdn.bootcss.com/angular.js/1.5.5/angular.min.js"></script>
	<script src="https://cdn.bootcss.com/angular.js/1.5.5/angular-animate.min.js"></script>
	<script src="https://cdn.bootcss.com/angular.js/1.5.5/angular-aria.min.js"></script>
	<script src="https://cdn.bootcss.com/angular.js/1.5.5/angular-messages.min.js"></script>

	<!-- Angular Material Library -->
	<script src="https://cdn.bootcss.com/angular-material/1.1.0/angular-material.min.js"></script>
	
	<script src="https://cdn.bootcss.com/qrcode-generator/1.2.0/qrcode.min.js"></script>
	<script src="https://cdn.bootcss.com/angular-qrcode/7.2.0/angular-qrcode.min.js"></script>

	<!-- Your application bootstrap  -->
	<script type="text/javascript">    
		/**
		* You must include the dependency on 'ngMaterial' 
		*/
	  	angular.module('DownloadApp', ['ngMaterial', 'monospaced.qrcode']).
	  		config(['$compileProvider', function ($compileProvider) {
          		$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|itms-services):/);
    		}]).
    		controller('DownloadCtrl', function($scope, $mdToast) {
				document.getElementById("downloadLink").style.display = "";
				document.getElementById("downloadLinkForWechat").style.display = "";
				document.getElementById("downloadLinkForUnsupportBrowser").style.display = "none";
		  		$scope.isWechat = true;
		  		var ua = navigator.userAgent.toLowerCase();
		  		if (/micromessenger/.test(ua)) {
		  			
		  		} else {
		  			$scope.isWechat = false;
	  			}
	  			if (/iphone/.test(ua)) {
	  				$scope.downloadURL = "itms-services://?action=download-manifest&url=https://intalinx.oschina.io/youbeile/intalinx.plist";
	  			} else {
	  				$scope.downloadURL = "https://intalinx.oschina.io/youbeile/IntaLinxMobile.apk";
	  			}

		  		$scope.download = function() {
		  			$mdToast.show($mdToast.simple()
		  				.textContent('已经开始下载，请到Home页面确认下载安装状况。'));
		  		}
			});
	</script>
  
	<script>
		(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
		(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
		m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
		})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

		ga('create', 'UA-83557304-1', 'auto');
		ga('send', 'pageview');

	</script>
</body>
</html>
